package com.kkb.kkbportal.service.impl;


import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kkb.kkbcommon.exception.Asserts;
import com.kkb.kkbportal.dao.CarouselMapper;
import com.kkb.kkbportal.domain.Carousel;
import com.kkb.kkbportal.service.CarouselService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 杜垣均
 * @title: CarouselServiceImpl
 * @projectName kkb-parent-v2
 * @description 轮播图后台管理
 * @data 19:30 2021/8/19
 */
@Service
public class CarouselServiceImpl extends ServiceImpl<CarouselMapper, Carousel> implements CarouselService {


    @Override
    public PageInfo<Carousel> selectCarouselList(Carousel carousel, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Carousel> list = this.lambdaQuery().eq(ObjectUtil.isNotNull(carousel.getId()), Carousel::getId, carousel.getId())
                .eq(ObjectUtil.isNotNull(carousel.getState()), Carousel::getState, carousel.getState())
                .eq(ObjectUtil.isNotNull(carousel.getUpdateTime()), Carousel::getUpdateTime, carousel.getUpdateTime())
                .list();

        return  new PageInfo<>(list);
    }
}
